<?php include "../public/header.php";?>
<?php include "../public/header_edit.php";?>
<link rel="stylesheet" type="text/css" href="/static/component/laytp/module/cityPicker/city-picker.css">

<body id="optPage">
<form class="layui-form layui-form-pane" id="commentForm">
    <div class="page-title"><div class="page-title-con"><span>编辑工程账户登记</span><div class="move_title"></div><?php include "../public/sub.php";?></div></div>
    <div class="main-container">
        <div class="block-generic">
            <div class="layui-form-item">
                <div class="layui-row layui-col-space10">
                    <div class="edittits"><span>基本信息</span></div>
                </div>
            </div>
            <div class="layui-form-item">
                <div class="layui-row layui-col-space10">
                    <div class="layui-col-md12">
                        <label class="layui-form-label"><text>*</text>工程名称</label>
                        <div class="layui-input-block">
                            <input type="text" readonly name="enginid" class="layui-input enginid" onclick="openPage('../public/choose_engin.php?dom=enginid&page=kaoacc','80%','80%')">
                            <div class="choose_div" id="enginid" key="1"></div>
                            <span class="choose_one" onclick="openPage('../public/choose_engin.php?dom=enginid&page=kaoacc','80%','80%')"><i class="layui-icon layui-icon-search"></i></span>
                        </div>
                    </div>
                </div>
            </div>
            <div class="layui-form-item">
                <div class="layui-row layui-col-space10">
                    <div class="layui-col-md6">
                        <label class="layui-form-label"><text>*</text>农民工工资专户是否开设</label>
                        <div class="layui-input-block">
                            <select id="nongkai" name="nongkai" lay-filter="nongkai">
                                <option value="">请选择</option>
                                <option value="是">是</option>
                                <option value="否">否</option>
                            </select>
                            <p class="error" id="nongkai_error" style="margin: 0;"></p>
                        </div>
                    </div>
                    <div class="layui-col-md6">
                        <label class="layui-form-label"><text>*</text>是否启用</label>
                        <div class="layui-input-block">
                            <select id="nongqi" name="nongqi" lay-filter="nongqi">
                                <option value="">请选择</option>
                                <option value="是">是</option>
                                <option value="否">否</option>
                            </select>
                            <p class="error" id="nongqi_error" style="margin: 0;"></p>
                        </div>
                    </div>
                </div>
            </div>


            <div class="layui-form-item">
                <div class="layui-row layui-col-space10">
                    <div class="layui-col-md6">
                        <label class="layui-form-label"><text>*</text>监管账户是否开设</label>
                        <div class="layui-input-block">
                            <select id="jiankai" name="jiankai" lay-filter="jiankai">
                                <option value="">请选择</option>
                                <option value="是">是</option>
                                <option value="否">否</option>
                            </select>
                            <p class="error" id="jiankai_error" style="margin: 0;"></p>
                        </div>
                    </div>
                    <div class="layui-col-md6">
                        <label class="layui-form-label"><text>*</text>是否启用</label>
                        <div class="layui-input-block">
                            <select id="jianqi" name="jianqi" lay-filter="jianqi">
                                <option value="">请选择</option>
                                <option value="是">是</option>
                                <option value="否">否</option>
                            </select>
                            <p class="error" id="jianqi_error" style="margin: 0;"></p>
                        </div>
                    </div>
                </div>
            </div>


            <div class="layui-form-item height_auto">
                <div class="layui-row layui-col-space10">
                    <div class="layui-col-md12">
                        <label class="layui-form-label label_textarea">备注</label>
                        <div class="layui-input-block">
                            <textarea id="explain" name="explain" placeholder="请输入" class="layui-textarea"></textarea>
                        </div>
                    </div>
                </div>
            </div>

            <?php include '../public/upinfo.php'?>
        </div>

    </div>
</form>
<script>
    var param_id = getQueryVariable('id') || 0;


    layui.use(['laytp', 'form'], function() {
        var form = layui.form, layer = layui.layer;
        render_input_attr();

        facade.ajax({type: 'get', url: ask_kaoacc_edit,data:{id:param_id}}).done(function(res){
            if (res.code === 2000) {
                var data = res.data.data;

                $("#nongkai").val(data.nongkai);
                $("#nongqi").val(data.nongqi);
                $("#jiankai").val(data.jiankai);
                $("#jianqi").val(data.jianqi);
                $("#explain").val(data.explain);

                var engininfo = res.data.engininfo;
                if(engininfo){
                    set_choose_btn('enginid',engininfo.id,engininfo.name);
                }

                public_upload_file_load('upload_files', res.data.files);
                render_from();
            }
        });


        form.on('select(nongkai)', function(data){
            if(data.value == ''){
                $('#nongkai_error').show().text('请选择');
                $('#nongkai_error').parent().find('input').addClass('select_error');
            }else{
                $('#nongkai_error').hide();
                $('#nongkai_error').parent().find('input').removeClass('select_error');
            }
        });
        form.on('select(nongqi)', function(data){
            if(data.value == ''){
                $('#nongqi_error').show().text('请选择');
                $('#nongqi_error').parent().find('input').addClass('select_error');
            }else{
                $('#nongqi_error').hide();
                $('#nongqi_error').parent().find('input').removeClass('select_error');
            }
        });

        form.on('select(jiankai)', function(data){
            if(data.value == ''){
                $('#jiankai_error').show().text('请选择');
                $('#jiankai_error').parent().find('input').addClass('select_error');
            }else{
                $('#jiankai_error').hide();
                $('#jiankai_error').parent().find('input').removeClass('select_error');
            }
        });
        form.on('select(jianqi)', function(data){
            if(data.value == ''){
                $('#jianqi_error').show().text('请选择');
                $('#jianqi_error').parent().find('input').addClass('select_error');
            }else{
                $('#jianqi_error').hide();
                $('#jianqi_error').parent().find('input').removeClass('select_error');
            }
        });


        form.on('submit(add)', function(data){
            var validRes = $("#commentForm").valid();
            data.field.enginid = get_choose_val('enginid');
            formValid('enginid');
            if(data.field.enginid == undefined || !data.field.enginid){
                validRes = false;
            }

            if(data.field.nongkai == ''){
                $('#nongkai_error').show().text('请选择');
                $('#nongkai_error').parent().find('input').addClass('select_error');
                validRes = false;
            }else{
                $('#nongkai_error').hide();
                $('#nongkai_error').parent().find('input').removeClass('select_error');
            }
            if(data.field.nongqi == ''){
                $('#nongqi_error').show().text('请选择');
                $('#nongqi_error').parent().find('input').addClass('select_error');
                validRes = false;
            }else{
                $('#nongqi_error').hide();
                $('#nongqi_error').parent().find('input').removeClass('select_error');
            }

            if(data.field.jiankai == ''){
                $('#jiankai_error').show().text('请选择');
                $('#jiankai_error').parent().find('input').addClass('select_error');
                validRes = false;
            }else{
                $('#jiankai_error').hide();
                $('#jiankai_error').parent().find('input').removeClass('select_error');
            }
            if(data.field.jianqi == ''){
                $('#jianqi_error').show().text('请选择');
                $('#jianqi_error').parent().find('input').addClass('select_error');
                validRes = false;
            }else{
                $('#jianqi_error').hide();
                $('#jianqi_error').parent().find('input').removeClass('select_error');
            }

            if(!validRes){return false;}



            data = parseMoney(data);
            data.field.id = param_id;
            data.field.files = public_upload_file_value('upload_files');
            facade.ajax({url: ask_kaoacc_edit, data:data.field}).done(function(res){
                if (res.code === 2000) {
                    dataPostTimeOut();
                }
            });

            return false;
        });

    });

</script>
</body>
</html>
